Home

Operator Usage

Name

transitive

Description

transitive[op] input-seq
transitive[op, max-steps] input-seq
Implements operators that are transitive.
max-steps is the max number of steps until the transitiveness "wears" off.
Most common example is the "is-a" operator
Say A is-a B, B is-a C, C is-a D, then A is-a B, C and D
Note that if the relation is "fuzzy" then transitive[] respects that too.
In which case we can use drop-below[] to decide when the transitiveness has worn off.
Note that an infinite loop is possible if the graph contains a loop,
so we try to check for that case.
Also, the result can potentially grow exponentially with each step,
so if that is possible in your use case, set max-steps to something managable.
For example, transitive[links-to] |starting web page>
could grow large very rapidly.


Examples

-- first, the Socrates example:
is-a |Socrates> => |human>
is-a |human> => |mortal>

-- so we can conclude:
transitive[is-a] |Socrates>
    |human> + |mortal>

-- second, a movie based example:
is-a-kind-of |British comedy> => |comedy>
is-a-kind-of |comedy> => |film>

-- so we can conclude:
transitive[is-a-kind-of] |British comedy>
    |comedy> + |film>

-- next, a fuzzy transitive example:
is-a |A> => 0.8 |B>
is-a |B> => 0.5 |C>
is-a |C> => 0.9 |D>
is-a |D> => 0.2 |E>

-- so we can conclude:
transitive[is-a] |A>
    0.800000|B> + 0.400000|C> + 0.360000|D> + 0.072000|E>

-- and we can combine this with a drop-below[threshold] operator:
drop-below[0.3] transitive[is-a] |A>
    0.800000|B> + 0.400000|C> + 0.360000|D>


See also

stransitive, drop-below transitive-operators.sw4

Operator type

sequence compound context